package com.example.psysystemhomework.alert;

import android.app.AlertDialog;
import android.content.Context;
import android.view.View;

import com.example.psysystemhomework.R;
import com.example.psysystemhomework.bean.EmotionBean;
import com.example.psysystemhomework.util.ChartUtil;
import com.github.mikephil.charting.charts.PieChart;

import java.util.ArrayList;

public class EmotionChartAlert extends AlertDialog {
    Context context;
    private PieChart mPiechart;
    private ArrayList<EmotionBean> list;

    public EmotionChartAlert(Context context, ArrayList<EmotionBean> list) {
        super(context);
        this.context = context;
        this.list = list;
    }

    public void showEmotionChart() {
        View view = View.inflate(context, R.layout.chart_alert, null);
        initViews(view);
        setView(view);
        ChartUtil chartUtil = new ChartUtil(mPiechart);
        chartUtil.showPieChart(list,30);
        setTitle("情感状态详情展示");
        show();

    }

    private void initViews(View view) {
        mPiechart = view.findViewById(R.id.pieChart);
    }
}
